<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<base href="<%=basePath%>">
		<title>查看购物车</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	</head>

	<body>
	<jsp:include page="../userview/top.jsp"></jsp:include>
					<div class="content">
					<div class="header">
            <h1 class="page-title">购物车</h1>
        </div>
        
                <ul class="breadcrumb">
            <li><a href="/WirelessOrder/home.do?flag=home">主页</a> <span class="divider">/</span></li>
            <li class="active">购物车</li>
        </ul>
        <% 
						if(request.getSession().getAttribute("loginUser")!=null){
				%>
					<!-- 首先判断session中是否有购物车对象 -->
				<s:if test="#session.allList.size!=0">	
					<div class="container-fluid">
	<div class="row-fluid" style="flaot:right;">
		<div class="span12">
			<table class="table table-striped">
				<thead>
					<tr>
						<th>
							店铺
						</th>
						<th>
							商品
						</th>
						<th>
							单价
						</th>
						<th>
							数量
						</th>
						<th>
							小计
						</th>
						<th>
							修改
						</th>
						<th>
							操作
						</th>
					</tr>
				</thead>
				<tbody>
								<s:iterator value="#session.allList" var="mod">
						<s:form action="updateCart" theme="simple">
						<tr class="info">
						<s:hidden name="cart.id" value="%{#request.id}"/>
						<s:hidden name="cart.itemId" value="%{#request.itemId}"/>
						<s:hidden name="cart.itemName" value="%{#request.itemName}"/>
						<s:hidden name="cart.itemType" value="%{#request.itemType}"/>
						<s:hidden name="cart.itemNum" value="%{#request.itemNum}"/>
						<s:hidden name="cart.itemPrice" value="%{#request.itemPrice}"/>
						<s:hidden name="cart.itemDescription" value="%{#request.itemDescription}"/>
						<s:hidden name="cart.shopId" value="%{#request.shopId}"/>
						
					      <td><a href="showshopItem?shopId=<s:property value="%{#request.shopId}"/>"><s:property value="%{#request.shopName}"/></a></td>
					      <td><a href="getItem?itemId=<s:property value="%{#request.itemId}"/>"><s:property value="%{#request.itemName}"/></a></td>
					       <td><s:property value="%{#request.itemPrice}"/></td>
					       <td><s:textfield id="number" name="cart.count" value="%{#request.count}" style="width:30px;" onkeyup="if(!/^([1-9]|[1-9][0-9]|100)$/.test(this.value)){alert('请输入1-100的整数')} this.value=this.value.replace(/\D/g,'')" 
										onafterpaste="if(!/^([1-9]|[1-9][0-9]|100)$/.test(this.value)){alert('请输入1-100的整数')} this.value=this.value.replace(/\D/g,'')"/></td>
					       <td><s:property value="%{#request.count*#request.itemPrice}"/></td>
					       <td>
					        <button type="submit" style="background-image: url('cart/mod.png');width:36px;height:36px;background-color:#d9edf7;border:0px"></button>
					       </td>
					       <td><a href="deleteItemFormCart?itemId=<s:property value="%{#request.itemId}"/>">删除</a></td>
    					</tr>
    					</s:form>		
			</s:iterator>

							</tbody>
			</table>
			<div class="span12"  style="padding-left:85%;">
			 <span class="label badge-important">总价:<%=request.getSession().getAttribute("totalPrice") %></span>
		</div>
		</div>
	</div>
	<s:form action="submit" theme="simple">
		<s:hidden name="cartlist.totalPrice" label="商家总价" value="1"/>
		<div align="right">
			 <button class="btn btn-danger" type="submit" style="margin-right:20px;">提交订单</button>
		</div>
		</s:form>
</div>
		<div class="form-actions">
								
								<a href="javascript:history.back();">
								<input type="button" class="btn" value="返  回">
							  </a>
			</s:if>
				<s:else>
					 <div style="height: 80px;width: 304px;color: #7ABD54;margin: 10% 0 10% 35%;">
								<div >
								<center><img src="cart/cart.jpg" style="width:66px;height:52px;margin-bottom:10px;"><font style="font: 24px/40px 微软雅黑;height:52px; line-height:80px;">购物车为空,赶紧行动吧!</a></font></center>
								</div>
							</div>
				</s:else>
				</div>
				</div>
				
				<% }
					else{
				%>
					 <div style="height: 80px;width: 304px;color: #7ABD54;margin: 10% 0 10% 35%;">
								<div >
								<center><font style="font: 24px/40px 微软雅黑;height:40px; line-height:80px;">你还没有登录，请<a href="login.jsp">登录</a></font></center>
								</div>
							</div>
				<%} %>
	</body>
</html>
